<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@include file="../common/taglib.jsp" %>

<!DOCTYPE html>
<html>
  <head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>我的首页</title>
	<meta http-equiv="X-UA-Compatible" content="IE=11; IE=10; IE=9; IE=8; IE=7; IE=EDGE">
	
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/header.css"/>">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/common.css"/>">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/public.css"/>">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/default.css"/>">
	<link rel="stylesheet" type="text/css" href="<c:url value="/css/footer.css"/>">
	<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
		<script type="text/javascript" src="<c:url value="/js/ajaxfileupload.js"/>"></script>
  </head>
  <script type="text/javascript">
  	function onload(value,url){
  		if(value==null || value==0){
  			alert("请先完善企业信息");
  			window.location.href="<c:url value="/company/register"/>";
  		}
  	}
  </script>
<body id="home" onload="onload(${hr.company.id})">

<jsp:include page="../common/hrheader.jsp"></jsp:include>

<div class="wrap clearfix">
	上传执照：<input type="file" name="photo" id="photo" onchange="change(this)">
			<img id="loading" src="<c:url value="/images/loading.gif"/>" style="display:none">
			<input type="submit" value="上传" onclick="uploadFile(${companyId})">
			<span style="color:red" id="msg"></span><br>
			<br><a href="<c:url value="/home/index"/>">稍后再填</a><br>
			<img alt="" src="" id="img">

</div>
<script type="text/javascript">
		function uploadFile(companyId){ 
			   $("#loading")
		     .ajaxStart(function(){
		         $(this).show();
		     })
		     .ajaxComplete(function(){
		         $(this).hide();
		     });
		 $.ajaxFileUpload({  
		         url:"http://localhost:8080/ersup/upload?companyId="+companyId+"&method=companylicense",            //需要链接到服务器地址  
		         secureuri:false,  
		         fileElementId:'photo',                        //文件选择框的id属性  
		         dataType:'json',
		         success: function(data, status){  
		             alert("上传成功");		             
		             document.getElementById("msg").innerHTML=data.result;
		             window.location.href="<c:url value='/home/index'/>";
		         }  
		     });  
		} 
		function change(input){
			var objectURL = getObjectURL(input.files[0]);
			if(objectURL){
				$('#img').attr('src',objectURL);
			}
		}
	
		
		function getObjectURL(file){
			var url = null;
			if(window.createObjectURL != undefined){
				url = window.createObjectURL(file);
			} else if(window.URL != undefined){
				url = window.URL.createObjectURL(file);
			} else if(window.webkitURL != undefined){
				rul = window.webkitURL.createObjectURL(file);
			}				
			return url;
		}
	</script>
<jsp:include page="../common/footer.jsp"></jsp:include>

</body>
</html>